$(function () {
  
    var answerId = getQueryString(" answerId ");
    console.log( answerId );
    //根据id从数据库中获取修改前的值
    $.post(
        "/citrusmonitor/answer.do?method=modifyA& answerId ="+ answerId ,

        function (data) {
         $("#answer_id").val(data. answerId ),
	     $("#question_id").val(data.questionId),
	     $("#expert_id").val(data.expertId),
         $("#responder").val(data.responder),
         $("#content").val(data.content),
	     $("#create_time").val(data.createTime)
        },
        "json"
    );
    //edit按钮绑定事件
    $("#edit").click(function () {

        $.post(
            "/citrusmonitor/answer.do?method=modifyA",
            {
            	"answerId": $("#answer_id").val(),
                "questionId": $("#question_id").val(),
                "expertId": $("#expert_id").val(),
                "responder": $("#responder").val(),
                "content": $("#content").val(),
                "createTime": $("#create_time").val()
            },
           function(res){
                console.log(res);
                res = JSON.parse(res);
                if(res.status==1){
                    alert("信息提示修改成功");
                }else{
                    alert("信息提示修改失败");
                }}
        )
    })
})

function getQueryString(name) {
    var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
    console.log(reg );
    var r = window.parent.document.getElementById("rightframe").contentWindow.location.search.substr(1).match(reg);
    if(r!=null){
        return  unescape(r[2]);
    }
    return null;
}
